home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyo (Python 2.5)
-
- __revision__ = '$Id: sysconfig.py 52234 2006-10-08 17:50:26Z ronald.oussoren $'
- import os
- import re
- import string
- import sys
- from distutils.errors import DistutilsPlatformError
- PREFIX = os.path.normpath(sys.prefix)
- EXEC_PREFIX = os.path.normpath(sys.exec_prefix)
- argv0_path = os.path.dirname(os.path.abspath(sys.executable))
- landmark = os.path.join(argv0_path, 'Modules', 'Setup')
- python_build = os.path.isfile(landmark)
- del landmark
-
- def get_python_version():
- return sys.version[:3]
-
-
- def get_python_inc(plat_specific = 0, prefix = None):
- if prefix is None:
- if not plat_specific or EXEC_PREFIX:
- pass
- prefix = PREFIX
-
- if os.name == 'posix':
- if python_build:
- base = os.path.dirname(os.path.abspath(sys.executable))
- if plat_specific:
- inc_dir = base
- else:
- inc_dir = os.path.join(base, 'Include')
- if not os.path.exists(inc_dir):
- inc_dir = os.path.join(os.path.dirname(base), 'Include')
-
- return inc_dir
-
- return os.path.join(prefix, 'include', 'python' + get_python_version())
- elif os.name == 'nt':
- return os.path.join(prefix, 'include')
- elif os.name == 'mac':
- if plat_specific:
- return os.path.join(prefix, 'Mac', 'Include')
- else:
- return os.path.join(prefix, 'Include')
- elif os.name == 'os2':
- return os.path.join(prefix, 'Include')
- else:
- raise DistutilsPlatformError("I don't know where Python installs its C header files on platform '%s'" % os.name)
-
-
- def get_python_lib(plat_specific = 0, standard_lib = 0, prefix = None):
- if prefix is None:
- if not plat_specific or EXEC_PREFIX:
- pass
- prefix = PREFIX
-
- if os.name == 'posix':
- libpython = os.path.join(prefix, 'lib', 'python' + get_python_version())
- if standard_lib:
- return libpython
- else:
- return os.path.join(libpython, 'site-packages')
- elif os.name == 'nt':
- if standard_lib:
- return os.path.join(prefix, 'Lib')
- elif get_python_version() < '2.2':
- return prefix
- else:
- return os.path.join(PREFIX, 'Lib', 'site-packages')
- elif os.name == 'mac':
- if plat_specific:
- if standard_lib:
- return os.path.join(prefix, 'Lib', 'lib-dynload')
- else:
- return os.path.join(prefix, 'Lib', 'site-packages')
- elif standard_lib:
- return os.path.join(prefix, 'Lib')
- else:
- return os.path.join(prefix, 'Lib', 'site-packages')
- elif os.name == 'os2':
- if standard_lib:
- return os.path.join(PREFIX, 'Lib')
- else:
- return os.path.join(PREFIX, 'Lib', 'site-packages')
- else:
- raise DistutilsPlatformError("I don't know where Python installs its library on platform '%s'" % os.name)
-
-
- def customize_compiler(compiler):
- if compiler.compiler_type == 'unix':
- (cc, cxx, opt, cflags, ccshared, ldshared, so_ext) = get_config_vars('CC', 'CXX', 'OPT', 'CFLAGS', 'CCSHARED', 'LDSHARED', 'SO')
- if os.environ.has_key('CC'):
- cc = os.environ['CC']
-
- if os.environ.has_key('CXX'):
- cxx = os.environ['CXX']
-
- if os.environ.has_key('LDSHARED'):
- ldshared = os.environ['LDSHARED']
-
- if os.environ.has_key('CPP'):
- cpp = os.environ['CPP']
- else:
- cpp = cc + ' -E'
- if os.environ.has_key('LDFLAGS'):
- ldshared = ldshared + ' ' + os.environ['LDFLAGS']
-
- if os.environ.has_key('CFLAGS'):
- cflags = opt + ' ' + os.environ['CFLAGS']
- ldshared = ldshared + ' ' + os.environ['CFLAGS']
-
- if os.environ.has_key('CPPFLAGS'):
- cpp = cpp + ' ' + os.environ['CPPFLAGS']
- cflags = cflags + ' ' + os.environ['CPPFLAGS']
- ldshared = ldshared + ' ' + os.environ['CPPFLAGS']
-
- cc_cmd = cc + ' ' + cflags
- compiler.set_executables(preprocessor = cpp, compiler = cc_cmd, compiler_so = cc_cmd + ' ' + ccshared, compiler_cxx = cxx, linker_so = ldshared, linker_exe = cc)
- compiler.shared_lib_extension = so_ext
-
-
-
- def get_config_h_filename():
- if python_build:
- inc_dir = argv0_path
- else:
- inc_dir = get_python_inc(plat_specific = 1)
- if get_python_version() < '2.2':
- config_h = 'config.h'
- else:
- config_h = 'pyconfig.h'
- return os.path.join(inc_dir, config_h)
-
-
- def get_makefile_filename():
- if python_build:
- return os.path.join(os.path.dirname(sys.executable), 'Makefile')
-
- lib_dir = get_python_lib(plat_specific = 1, standard_lib = 1)
- return os.path.join(lib_dir, 'config', 'Makefile')
-
-
- def parse_config_h(fp, g = None):
- if g is None:
- g = { }
-
- define_rx = re.compile('#define ([A-Z][A-Za-z0-9_]+) (.*)\n')
- undef_rx = re.compile('/[*] #undef ([A-Z][A-Za-z0-9_]+) [*]/\n')
- while None:
- line = fp.readline()
- if not line:
- break
-
- m = define_rx.match(line)
- if m:
- (n, v) = m.group(1, 2)
-
- try:
- v = int(v)
- except ValueError:
- pass
-
- g[n] = v
- continue
- m = undef_rx.match(line)
- if m:
- g[m.group(1)] = 0
- continue
- continue
- return g
-
- _variable_rx = re.compile('([a-zA-Z][a-zA-Z0-9_]+)\\s*=\\s*(.*)')
- _findvar1_rx = re.compile('\\$\\(([A-Za-z][A-Za-z0-9_]*)\\)')
- _findvar2_rx = re.compile('\\${([A-Za-z][A-Za-z0-9_]*)}')
-
- def parse_makefile(fn, g = None):
- TextFile = TextFile
- import distutils.text_file
- fp = TextFile(fn, strip_comments = 1, skip_blanks = 1, join_lines = 1)
- if g is None:
- g = { }
-
- done = { }
- notdone = { }
- while None:
- line = fp.readline()
- if line is None:
- break
-
- m = _variable_rx.match(line)
- if m:
- (n, v) = m.group(1, 2)
- v = string.strip(v)
- if '$' in v:
- notdone[n] = v
- else:
-
- try:
- v = int(v)
- except ValueError:
- pass
-
- done[n] = v
- continue
- while notdone:
- for name in notdone.keys():
- value = notdone[name]
- if not _findvar1_rx.search(value):
- pass
- m = _findvar2_rx.search(value)
- if m:
- n = m.group(1)
- found = True
- if done.has_key(n):
- item = str(done[n])
- elif notdone.has_key(n):
- found = False
- elif os.environ.has_key(n):
- item = os.environ[n]
- else:
- done[n] = item = ''
- if found:
- after = value[m.end():]
- value = value[:m.start()] + item + after
- if '$' in after:
- notdone[name] = value
- else:
-
- try:
- value = int(value)
- except ValueError:
- done[name] = string.strip(value)
-
- done[name] = value
- del notdone[name]
-
- found
- del notdone[name]
-
- fp.close()
- g.update(done)
- return g
-
-
- def expand_makefile_vars(s, vars):
- while not _findvar1_rx.search(s):
- m = _findvar2_rx.search(s)
- if m:
- (beg, end) = m.span()
- s = s[0:beg] + vars.get(m.group(1)) + s[end:]
- continue
- break
- continue
- return s
-
- _config_vars = None
-
- def _init_posix():
- global _config_vars
- g = { }
-
- try:
- filename = get_makefile_filename()
- parse_makefile(filename, g)
- except IOError:
- msg = None
- my_msg = 'invalid Python installation: unable to open %s' % filename
- if hasattr(msg, 'strerror'):
- my_msg = my_msg + ' (%s)' % msg.strerror
-
- raise DistutilsPlatformError(my_msg)
-
-
- try:
- filename = get_config_h_filename()
- parse_config_h(file(filename), g)
- except IOError:
- msg = None
- my_msg = 'invalid Python installation: unable to open %s' % filename
- if hasattr(msg, 'strerror'):
- my_msg = my_msg + ' (%s)' % msg.strerror
-
- raise DistutilsPlatformError(my_msg)
-
- if sys.platform == 'darwin' and g.has_key('MACOSX_DEPLOYMENT_TARGET'):
- cfg_target = g['MACOSX_DEPLOYMENT_TARGET']
- cur_target = os.getenv('MACOSX_DEPLOYMENT_TARGET', '')
- if cur_target == '':
- cur_target = cfg_target
- os.putenv('MACOSX_DEPLOYMENT_TARGET', cfg_target)
- elif map(int, cfg_target.split('.')) > map(int, cur_target.split('.')):
- my_msg = '$MACOSX_DEPLOYMENT_TARGET mismatch: now "%s" but "%s" during configure' % (cur_target, cfg_target)
- raise DistutilsPlatformError(my_msg)
-
-
- if python_build:
- g['LDSHARED'] = g['BLDSHARED']
- elif get_python_version() < '2.1':
- if sys.platform == 'aix4':
- python_lib = get_python_lib(standard_lib = 1)
- ld_so_aix = os.path.join(python_lib, 'config', 'ld_so_aix')
- python_exp = os.path.join(python_lib, 'config', 'python.exp')
- g['LDSHARED'] = '%s %s -bI:%s' % (ld_so_aix, g['CC'], python_exp)
- elif sys.platform == 'beos':
- python_lib = get_python_lib(standard_lib = 1)
- linkerscript_path = string.split(g['LDSHARED'])[0]
- linkerscript_name = os.path.basename(linkerscript_path)
- linkerscript = os.path.join(python_lib, 'config', linkerscript_name)
- g['LDSHARED'] = '%s -L%s/lib -lpython%s' % (linkerscript, PREFIX, get_python_version())
-
-
- _config_vars = g
-
-
- def _init_nt():
- global _config_vars
- g = { }
- g['LIBDEST'] = get_python_lib(plat_specific = 0, standard_lib = 1)
- g['BINLIBDEST'] = get_python_lib(plat_specific = 1, standard_lib = 1)
- g['INCLUDEPY'] = get_python_inc(plat_specific = 0)
- g['SO'] = '.pyd'
- g['EXE'] = '.exe'
- _config_vars = g
-
-
- def _init_mac():
- global _config_vars
- g = { }
- g['LIBDEST'] = get_python_lib(plat_specific = 0, standard_lib = 1)
- g['BINLIBDEST'] = get_python_lib(plat_specific = 1, standard_lib = 1)
- g['INCLUDEPY'] = get_python_inc(plat_specific = 0)
- import MacOS
- if not hasattr(MacOS, 'runtimemodel'):
- g['SO'] = '.ppc.slb'
- else:
- g['SO'] = '.%s.slb' % MacOS.runtimemodel
- g['install_lib'] = os.path.join(EXEC_PREFIX, 'Lib')
- g['install_platlib'] = os.path.join(EXEC_PREFIX, 'Mac', 'Lib')
- g['srcdir'] = ':'
- _config_vars = g
-
-
- def _init_os2():
- global _config_vars
- g = { }
- g['LIBDEST'] = get_python_lib(plat_specific = 0, standard_lib = 1)
- g['BINLIBDEST'] = get_python_lib(plat_specific = 1, standard_lib = 1)
- g['INCLUDEPY'] = get_python_inc(plat_specific = 0)
- g['SO'] = '.pyd'
- g['EXE'] = '.exe'
- _config_vars = g
-
-
- def get_config_vars(*args):
- global _config_vars
- if _config_vars is None:
- func = globals().get('_init_' + os.name)
- if func:
- func()
- else:
- _config_vars = { }
- _config_vars['prefix'] = PREFIX
- _config_vars['exec_prefix'] = EXEC_PREFIX
- if sys.platform == 'darwin':
- kernel_version = os.uname()[2]
- major_version = int(kernel_version.split('.')[0])
- if major_version < 8:
- for key in ('LDFLAGS', 'BASECFLAGS', 'CFLAGS', 'PY_CFLAGS', 'BLDSHARED'):
- flags = _config_vars[key]
- flags = re.sub('-arch\\s+\\w+\\s', ' ', flags)
- flags = re.sub('-isysroot [^ \t]*', ' ', flags)
- _config_vars[key] = flags
-
-
-
-
- if args:
- vals = []
- for name in args:
- vals.append(_config_vars.get(name))
-
- return vals
- else:
- return _config_vars
-
-
- def get_config_var(name):
- return get_config_vars().get(name)
-
-